package io.github.biezhi.elves.main;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import io.github.biezhi.elves.spider.BidSpider;
import io.github.biezhi.elves.spider.CompImportSpider;
import io.github.biezhi.elves.spider.CompSpider;
import io.github.biezhi.elves.spider.CreditReportSpider;
import io.github.biezhi.elves.spider.FsggzySpider;
import io.github.biezhi.elves.spider.HotelSpider;
import io.github.biezhi.elves.spider.JmggzySpider;
import io.github.biezhi.elves.spider.NoticeCrawlSpider;
import io.github.biezhi.elves.spider.QccBidDetailSpider;
import io.github.biezhi.elves.spider.QccBidSpider;
import io.github.biezhi.elves.spider.QccBidUrlDateSpider;
import io.github.biezhi.elves.spider.QccBidUrlResolveSpider;
import io.github.biezhi.elves.spider.QccCombine;
import io.github.biezhi.elves.spider.QccRealTimeSpider;
import io.github.biezhi.elves.spider.QccSpider;
import io.github.biezhi.elves.spider.QccUniscidSpider;
import io.github.biezhi.elves.spider.QccResolve;
import io.github.biezhi.elves.spider.SgggzySpider;
import io.github.biezhi.elves.spider.ShareholderSpider;
import io.github.biezhi.elves.spider.YjggzySpider;

/**
 * 爬取企查查网站信息入口类
 *
 */
@Configuration
public class ShareholderMain {
	@Autowired
	private HotelSpider hotelSpider;
	@Autowired
	private CompSpider compSpider;
	@Autowired
	private ShareholderSpider shareholderSpider;
	@Autowired
	private CompImportSpider compImportSpider;
	@Autowired
	private BidSpider bidSpider;
	@Autowired
	private FsggzySpider fsggzySpider;
	@Autowired
	private SgggzySpider sgggzySpider;
	@Autowired
	private JmggzySpider jmggzySpider;
	@Autowired
	private YjggzySpider yjggzySpider;
	@Autowired
	private QccSpider qccSpider;
	@Autowired
	private NoticeCrawlSpider noticeCrawlSpider;
	@Autowired
	private QccResolve qccResolve;
	@Autowired
	private QccCombine qccCombine;
	@Autowired
	private QccRealTimeSpider qccRealTimeSpider;
	@Autowired
	private QccBidSpider qccBidSpider;
	@Autowired
	private QccBidUrlDateSpider qccBidUrlDateSpider;
	@Autowired
	private QccBidDetailSpider qccBidDetailSpider;
	@Autowired
	private QccBidUrlResolveSpider qccBidUrlResolveSpider;
	@Autowired
	private CreditReportSpider creditReportSpider;
	@Autowired
	private QccUniscidSpider qccUniscidSpider;
	
	/**
	 * 开始执行爬虫操作
	 * @throws Exception 
	 */
	public void startShareholder(int type) throws Exception{
		switch(type){
			case 1:
				//爬取企查查数据
				shareholderSpider.startShareholder();
				break;
			case 2:
				//爬取百度拾取坐标系统爬虫酒店/会所数据
				hotelSpider.startBaiduHotel();
				break;
			case 3:
				//开始根据执行企业名称批量更新爬取列表数据表地市id和地市名称
				shareholderSpider.startBatchUpdateCrawlTableDataForCityIdAndCityName();
				break;
			case 4:
				//开始根据地市ID补充企业图谱数据
				shareholderSpider.startSupplementEnterpriseProfileData();
				break;
			case 5:
				//开始根据地市ID补充投资族谱数据
				shareholderSpider.startFamilyInvestmentInfoData();
				break;
			case 6:
				//开始关联图谱数据测试
				shareholderSpider.startRelationProfileInfoData();
				break;
			case 7:
				//开始执行爬去百度拾取坐标系统更新企业导入表操作
				compImportSpider.startCompImport();
				break;
			case 8:
				//开始执行爬取企查查企业地址、logo、简介
				compSpider.startQccCompAddrAndLogoAndDesc();
				break;
			case 9:
				//开始执行爬取投标公告数据
				bidSpider.startBid();
				break;
			case 10:
				//变更公告入库(http://www.gdgpo.gov.cn/)
				bidSpider.resolveChangeNoticeHtml();
				break;
			case 11:
				//中标公告入库(http://www.gdgpo.gov.cn/)
				bidSpider.resolveWinBiddingHtml();
				break;
			case 12:
				//爬取佛山记录表
				fsggzySpider.saveFsRecord();
				break;
			case 13:
				//爬取佛山公告详情表
				fsggzySpider.saveFsDownload();
				break;
			case 14:
				//解析佛山页面文档
				fsggzySpider.resolveHtmlContent();
				break;
			case 15:
				//爬取韶关记录表
				sgggzySpider.saveSgRecord();
				break;
			case 16:
				//爬取韶关公告详情表
				sgggzySpider.saveSgDownload();
				break;
			case 17:
				//解析韶关中标公告文档
				sgggzySpider.resolveHtmlContent();
				break;
			case 18:
				//爬取江门记录表
				jmggzySpider.saveJmRecord();
				break;
			case 19:
				//爬取江门公告详情表
				jmggzySpider.saveJmDownload();
				break;
			case 20:
				//解析江门中标公告文档
				jmggzySpider.resolveHtmlContent();
				break;
			case 21:
				//爬取阳江记录表
				yjggzySpider.saveYjRecord();
				break;
			case 22:
				//爬取阳江公告详情表
				yjggzySpider.saveYjDownload();
				break;
			case 23:
				//爬取阳江中标公告文档
				yjggzySpider.resolveHtmlContent();
				break;
			case 24:
				//爬取企查查数据
				qccSpider.QccSpiderToDB();
				break;
			case 25:
				//开始执行爬取投标信息网数据
				noticeCrawlSpider.startBid();
				break;
			case 26:
				//解析企查查网页
				qccResolve.resolveQccHtml();
				break;
			case 27:
				//企查查：将解析的其他表数据合并到t_comp_basic_info
				qccCombine.jsonCombine();
				break;
			case 28:
				//爬取指定企业企查查网页数据
				qccRealTimeSpider.QccSpiderToDB();
				break;
			case 29:
				//爬取指定企业企查查公告列表链接数据
				qccBidSpider.QccSpiderToDB();
				break;
			case 30:
				//爬取指定企业企查查公告列表链接对应的网页数据
				qccBidUrlDateSpider.QccBidUrlSpiderToDB();
				break;
			case 31:
				//爬取原始招投标网页数据
				qccBidDetailSpider.bidDetailSpiderToDB();
				break;
			case 32:
				//爬取指定企业企查查公告列表链接对应的网页数据,并根据页面头部信息解析出来
				qccBidUrlResolveSpider.bidUrlResolveSpiderToDB();
				break;
			case 33:
				//爬取信用广东上的信用报告到数据库
				creditReportSpider.spiderCreditReportToDB();
				break;
			case 34:
				//爬取企业信用代码
				qccUniscidSpider.spiderUniscidToDB();
				break;
		}
	}
}